<?php

namespace app\apigovernment\controller;

use app\common\controller\Api;
use think\Config;
use think\Exception;

/**
 * 通知
 */
class GovernmentInform extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    protected $failException = true;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\apigovernment\model\GovernmentInform();
        if (!Config::get('fastadmin.usercenter')) {
            $this->error(__('User center already closed'));
        }
    }


    /**
     * 列表
     * @return void
     */
    public function list()
    {
        try {
            $data = $this->model->select();
            $this->success('ok', $data);
        } catch (Exception $e) {
            $this->error($e->getMessage());
        }
    }


    /**
     * 保存
     * @return void
     */
    public function save()
    {
        $input = input('post.');
        try {
            $id = $input['id'];
            unset($input['id']);
            $this->model->where('id', $id)->update($input);
            $this->success('保存成功');
        } catch (Exception $e) {
            $this->error($e->getMessage());
        }
    }





}